const express = require('express')
const path = require('path')
const app = express()
// app.engine('html', require('ejs'));
// 渲染视图所在位置，也就是模板所在位置
// app.set("views",path.join(__dirname,"./views"))
app.set("view engine",'ejs')
app.use(express.static(path.join(__dirname,'./public')))

app.get('/ejs',(req,res)=>{
    res.render('index')
})
app.get('/home',(req,res)=>{
    res.render('home',{
        title:'动态数据',
        students:[
            {id:1,name:'张三1',gender:1,hobbies:'看书，写完这个那个'},
            {id:1,name:'张三2',gender:1,hobbies:'看书，写完这个那个'},
            {id:1,name:'张三3',gender:1,hobbies:'看书，写完这个那个'},
            {id:1,name:'张三4',gender:1,hobbies:'看书，写完这个那个'},
            {id:1,name:'张三5',gender:1,hobbies:'看书，写完这个那个'},
            {id:1,name:'张三6',gender:1,hobbies:'看书，写完这个那个'},
            {id:1,name:'张三7',gender:1,hobbies:'看书，写完这个那个'},
        ],
        msg:'这是一条消息'
    })
})

app.listen(3000,()=>{
    console.log(`服务已经启动`);
})